using System;
using System.Windows.Forms;
using Deployment.CustomTasks.Controls;
using NAnt.Core;
using NAnt.Core.Attributes;

namespace Deployment.CustomTasks.Types
{
	public enum ControlType
	{
		CheckBox, File, Folder, String
	}

	[ElementName("control")]
	public class WizardScreenItemElement : Element, IUserControl
	{
		private string id;
		private string depends;
		private string title;
		private string _value;
		private ControlType controlType = Types.ControlType.String;

		public IUserControl GetUserControl()
		{
			IUserControl control;
			switch(ControlType)
			{
				case Types.ControlType.CheckBox:
					control = new CheckBoxControl();
					break;
				default:
					throw new ApplicationException();
			}
			control.Id = id;
			control.Title = title;
			return control;
		}

		[TaskAttribute("type", Required = false)]
		public ControlType ControlType
		{
			get { return controlType; }
			set { controlType = value; }
		}

		[TaskAttribute("id", Required = true)]
		public string Id
		{
			get { return id; }
			set { id = value; }
		}

		[TaskAttribute("depends", Required = false)]
		public string Depends
		{
			get { return depends; }
			set { depends = value; }
		}

		[TaskAttribute("title", Required = true)]
		public string Title
		{
			get { return title; }
			set { title = value; }
		}

		public event EventHandler<UserControlChangedEvent> DepencencyChanged;

		public string Value
		{
			get { return _value; }
		}

		public Control GetControl()
		{
			
			switch (ControlType)
			{
				case Types.ControlType.CheckBox:
					CheckBoxControl control = new CheckBoxControl();
					control.Id = Id;
					control.Title = title;
					return control;
					break;
				default:
					throw new ApplicationException();
			}
		}


		public void OnDependencyChanged(object sender, UserControlChangedEvent e)
		{
			throw new NotImplementedException();
		}
	}
}